package com.ruoyi.system.mapper;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.Article;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.mongodb.core.MongoTemplate;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: fulin
 * @Date: 2023/07/16/10:42
 * @Description:
 */
@Repository
public class ArticleMapper {

    @Autowired
    MongoTemplate mongoTemplate;


    //根据id查询文章
    public  Article findById(String id) {
        Article articles = mongoTemplate.findById(id, Article.class, "article");
        return articles;
    }

    //存入文章
   public Article save(String data,String id){
       Article article = new Article(id, "article", data, null);
       mongoTemplate.save(article,"article");
        return article;
    }
}
